﻿@model VOD.Models.Video
@if (false)
{
    <script type="text/javascript" src="../../../Scripts/jquery-vsdoc.js"></script>
}
@Html.HiddenFor(model=>model.CategoryID)
<div id="VideoBox">
    <table width="600" border="1" cellspacing="0" cellpadding="10">
        <tr>
            <th width="75">
                @Html.LabelFor(model => model.Name)：
            </th>
            <td colspan="3">
                @Html.TextBoxFor(model => model.Name, new { maxlength = 50, @class = "ui-widget-content text ui-corner-all" })
                @Html.ValidationMessageFor(model => model.Name)
            </td>
            <th width="200" rowspan="6">
                <img id="VideoPic" src="@Url.Content("~/Content/Images/VideoImg/" + Model.VideoID + ".jpg")" onerror="javascript:this.src='@Url.Content("~/Content/images/nopic.jpg")'" width="170" height="214" />
            </th>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.ShortTitle)：
            </th>
            <td width="76">
                @Html.TextBoxFor(model => model.ShortTitle, new { maxlength = 7, @class = "ui-widget-content text ui-corner-all" })
                @Html.ValidationMessageFor(model => model.ShortTitle)
            </td>
            <th width="75">@Html.LabelFor(model => model.LongTitle):</th>
            <td width="140">
                @Html.TextBoxFor(model => model.LongTitle, new { maxlength = 14, @class = "ui-widget-content text ui-corner-all" })
                @Html.ValidationMessageFor(model=>model.LongTitle)
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.ShowYear):
            </th>
            <td>
                @Html.TextBoxFor(model => model.ShowYear, new { maxlength = 4, @class = "ui-widget-content text ui-corner-all" })
                @Html.ValidationMessageFor(model => model.ShowYear)
            </td>
            <th>
                @Html.LabelFor(model => model.Director)：
            </th>
            <td>
                @Html.TextBoxFor(model => model.Director, new { @class = "ui-widget-content text ui-corner-all" })
                @Html.ValidationMessageFor(model => model.Director)
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Actor)：
            </th>
            <td colspan="3">
                @Html.TextBoxFor(model => model.Actor, new { maxlength = 256, @class = "ui-widget-content text ui-corner-all" })
                @Html.ValidationMessageFor(model => model.Actor)
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.LangID)：
            </th>
            <td>
                @Html.DropDownList("LangID")
            </td>
            <th>
                @Html.LabelFor(model => model.AreaID)：
            </th>
            <td>
                @Html.DropDownList("AreaID")
            </td>
        </tr>
        <tr>
            <th>
                图片上传：
            </th>
            <td colspan="3">
                <input id="PicUrl" type="file" name="PicUrl" />
            </td>
        </tr>
        <tr>
            <th>
                类别：
            </th>
            <td colspan="4">
                最多选择3个类别：
                <div class="chkTypeList clearfix">
                @{
                    var types = ViewBag.Types as List<VOD.ViewModels.AssignedTypeData>;
                    foreach(var type in types)
                    {
                        <p><input type="checkbox" name="Types" value="@type.TypeID" @(Html.Raw(type.Assigned ? "checked=\"checked\"" : "")) /> @type.TypeName</p>
                    }
                }
                </div>
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Intro)：
            </th>
            <td colspan="4">
                @Html.TextAreaFor(model => model.Intro, new { maxlength = 2048, @class = "ui-widget-content text ui-corner-all" })
                @Html.ValidationMessageFor(model => model.Intro)
            </td>
        </tr>

        <tr>
            <th colspan="5">
                <input class="ui-state-default ui-corner-all" type="submit" value="保存" />
                <input id="btnreset" class="ui-state-default ui-corner-all" type="reset" value="重置" />
            </th>
        </tr>
    </table>
</div>
<script type="text/javascript">
    $(function () {
        //Name输入框获得焦点
        $("#Name").focus();

        //按钮hover之后效果
        $("input.ui-state-default , a.ui-state-default").hover(
            function () { $(this).addClass('ui-state-hover'); },
            function () { $(this).removeClass('ui-state-hover'); }
        );

        //类型复选框组控制最多只能选择3项
        $(":checkbox[name='Types']").change(function (e) {
            CheckedMax3();
        });
        CheckedMax3();
        function CheckedMax3() {
            if ($(":checkbox[name='Types']:checked").length >= 3) {
                $(":checkbox[name='Types']:not(:checked)").attr("disabled", "disabled");
            }
            else {
                $(":checkbox[name='Types']:not(:checked)").removeAttr("disabled");
            }
        };
    });
</script>
@Content.Script("uploadPreview.js",Url)